package com.example.test622.ui.live

import android.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.Toast
import com.example.common.CommonAdapter
import com.example.common.mvi.BaseFragment
import com.example.net.entity.RecommonVideoEntity
import com.example.test622.BR
import com.example.test622.R
import com.example.test622.databinding.FragmentLiveBinding
import com.example.test622.ui.live.model.entity.LiveEntity


class LiveFragment : BaseFragment<FragmentLiveBinding,LiveViewModel>() {
	/**
	 * 使用lazy方式初始化adapter，确保其只在第一次访问时被创建。
	 * 这种方式可以避免在初始化时不必要的计算，同时也保证了adapter的线程安全。
	 *
	 * CommonAdapter是一个通用的适配器类，用于将数据集合绑定到视图上。
	 * 这里使用了Lambda表达式来指定item的布局文件和绑定变量，以便在item视图中使用。
	 * item_recommonlive是列表项的布局文件，BR.live是对应的变量绑定。
	 */
	val adapter by lazy {
		CommonAdapter<LiveEntity>({R.layout.item_recommonlive to BR.live})
	}
	override fun initView() {
		var list = mutableListOf<LiveEntity>()
		val img_header="https://sf3-cdn-tos.bdxiguastatic.com/img/pgc-image/0ab13d95b5ea4255b8761be0de22c7ca~300x300.image"
		list.add(LiveEntity(1,"Wandy","https://p1-dy.bytexservice.com/img/user-avatar/4b59e33dc88e2a7a537bfffbd5d1141a~300x300.image",30))
		list.add(LiveEntity(2,"Teddy","https://p3.bdxiguaimg.com/img/mosaic-legacy/6ee900022f6451ca01eb~0x0.image",40))
		list.add(LiveEntity(3,"Toney","https://sf6-cdn-tos.bdxiguastatic.com/img/user-avatar/7e60eacf9bb39d1418c49c0f0985d7d0~300x300.image",50))
		list.add(LiveEntity(4,"Toney","https://sf6-cdn-tos.bdxiguastatic.com/img/user-avatar/7e60eacf9bb39d1418c49c0f0985d7d0~300x300.image",50))
		list.add(LiveEntity(5,"Toney","https://sf6-cdn-tos.bdxiguastatic.com/img/user-avatar/7e60eacf9bb39d1418c49c0f0985d7d0~300x300.image",50))
		list.add(LiveEntity(6,"Toney","https://sf6-cdn-tos.bdxiguastatic.com/img/user-avatar/7e60eacf9bb39d1418c49c0f0985d7d0~300x300.image",50))
		list.add(LiveEntity(7,"Toney","https://sf6-cdn-tos.bdxiguastatic.com/img/user-avatar/7e60eacf9bb39d1418c49c0f0985d7d0~300x300.image",50))
		list.add(LiveEntity(8,"Toney","https://sf6-cdn-tos.bdxiguastatic.com/img/user-avatar/7e60eacf9bb39d1418c49c0f0985d7d0~300x300.image",50))
		adapter+=list
		binding.rvRecommendLive.adapter = adapter
	}
	
	override fun initData() {
	
	}
	
}